#include <bits/stdc++.h>
using namespace std;
using ll = long long;

ll rr() {
    ll s = 0, w = false, c = getchar();
    for (; !isdigit(c); c = getchar())
        w = w || c == '-';
    for (; isdigit(c); c = getchar())
        s = s * 10 + c - '0';
    return w ? -s : s;
}

// END OF HEADER

int c[100][100];

int main() {
    int n = rr();
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            c[i][j] = rr();
        }
    }
    int ans = 0x3f3f3f3f, sum = 0;
    vector<int> vis(n);
    std::function<void(int)> dfs = [&](int pos) {
        if (sum >= ans)
            return;
        if (pos == n) {
            ans = min(ans, sum);
        } else {
            for (int i = 0; i < n; i++) {
                if (vis[i])
                    continue;
                vis[i] = true, sum += c[pos][i];
                dfs(pos + 1);
                sum -= c[pos][i], vis[i] = false;
            }
        }
    };
    dfs(0);
    printf("%d", ans);
    return 0;
}
